package com.Apo1o.vo;

import com.Apo1o.entity.bhBasic;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

/**
 * @Auther: Apo1o.
 * @Date: 2024/5/7-05-07-18:38
 * @Description： com.Apo1o.vo
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class bhBasicInfoVo {
    private Integer id;

    private String name;

    private Double height;

    private Double weight;

    private Double bmi;

    private String bp;

    private Integer girth;

    private Integer hips;

    private Integer lungs;

    private String grip;

    private Double sar;

    private String slt;



    /**
     * 将bhBasic对象的属性值复制到bhBasicInfoVo对象中。
     * @param bhBasic 原始bhBasic对象
     * @return 复制后的bhBasicInfoVo对象
     * @throws IllegalArgumentException 如果bhBasic为null，则抛出此异常
     */
    public static bhBasicInfoVo fromBasic(bhBasic bhBasic) throws IllegalArgumentException {
        // 输入验证
        if (bhBasic == null) {
            throw new IllegalArgumentException("bhBasic对象不能为空");
        }

        bhBasicInfoVo bbInfoVo = new bhBasicInfoVo();
        try {
            // 异常处理：通过try-catch捕获潜在的异常
            BeanUtils.copyProperties(bhBasic, bbInfoVo);
        } catch (Exception e) {
            // 这里可以根据实际情况记录日志或者抛出一个更合适的异常
            // 例如，可以使用日志框架记录异常信息
            // Logger.error("复制bhBasic到bhBasicInfoVo时发生错误", e);
            throw new RuntimeException("属性复制过程中发生错误", e);
        }
        return bbInfoVo;
    }


}
